import type {ProvinceInfo, WeatherResponse} from "@/types/interface";
import weatherApi from "@/http/models/weather";


export default class WeatherUtil {
    provinces : ProvinceInfo[] =[
        {id: 0, province: ' 北京 ', code: 110000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 天津 ', code: 120000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 河北 ', code: 130000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 山西 ', code: 140000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 内蒙古 ', code: 150000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 辽宁 ', code: 210000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 吉林 ', code: 220000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 黑龙江 ', code: 230000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 上海 ', code: 310000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 江苏 ', code: 320000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 浙江 ', code: 330000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 安徽 ', code: 340000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 福建 ', code: 350000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 江西 ', code: 360000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 山东 ', code: 370000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 河南 ', code: 410000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 湖北 ', code: 420000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 湖南 ', code: 430000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 广东 ', code: 440000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 广西 ', code: 450000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 海南 ', code: 460000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 南海诸岛 ', code: 460000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 重庆 ', code: 500000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 四川 ', code: 510000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 贵州 ', code: 520000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 云南 ', code: 530000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 西藏 ', code: 540000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 陕西 ', code: 610000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 甘肃 ', code: 620000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 青海 ', code: 630000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 宁夏 ', code: 640000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 新疆 ', code: 650000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        /*{id: 0, province: ' 台湾 ', code: 710000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 香港 ', code: 810000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""},
        {id: 0, province: ' 澳门 ', code: 820000, weather: "", temperatureFloat: 0, humidityFloat: 0, updateTime: ""}*/
    ]

    async getWeather(provinceCode: number): Promise<WeatherResponse> {
        try {
            const response = await weatherApi.getWeather(provinceCode);
            return response;
        } catch (error) {
            console.error("获取天气信息失败:", error);
            throw error;
        }
    }
}